package org.base.mode.utils;

/**
 * 统一结果返回体
 * CRC
 * 2022/2/7
 */
public class R {

    /**
     * 返回状态码
     */
    private int code;

    /**
     * 返回消息内容
     */
    private String msg;

    /**
     * 返回对象
     */
    private Object data;

    public R() {
    }

    public R(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static R success() {
        return new R(BaseConstant.success,"成功",null);
    }

    public static R success(String msg) {
        return new R(BaseConstant.success,msg,null);
    }

    public static R success(Object data) {
        return new R(BaseConstant.success,"成功",data);
    }

    public static R success(String msg, Object data) {
        return new R(BaseConstant.success,msg,data);
    }


    public static R error() {
        return new R(BaseConstant.error,"错误",null);
    }

    public static R error(String msg) {
        return new R(BaseConstant.error,msg,null);
    }

    public static R error(String msg, Object data) {
        return new R(BaseConstant.error,msg,data);
    }

}
